package com.pshcp.doctor.tool;

import com.framework.exception.BizException;
import com.framework.thread.ReqComTool;
import com.framework.tool.CommonTool;
import com.framework.util.SystemUtil;
import com.pshcp.doctor.ao.patientcheckinsettings.SaveDoctorPatientCheckInSettingsAO;
import com.pshcp.domain.model.DoctorPatientCheckInSettings;

import java.util.Date;

/**
 * @Description: TODO
 * @Author: xiaoche
 * @Date: 2022/11/3 18:21
 */
public class DoctorPatientCheckInSettingsTool {

    public static DoctorPatientCheckInSettings buildDefaultDoctorPatientCheckInSettings() {
        DoctorPatientCheckInSettings doctorPatientCheckInSettings = new DoctorPatientCheckInSettings();
        doctorPatientCheckInSettings.setDoctorId(ReqComTool.getUserId());
        doctorPatientCheckInSettings.setCheckInAllowedFlag(1);
        doctorPatientCheckInSettings.setWelcomeMessage(null);
        doctorPatientCheckInSettings.setPatientSessionStatus(1);
        doctorPatientCheckInSettings.setRuleType(0);
        doctorPatientCheckInSettings.setFreeDays(3);
        doctorPatientCheckInSettings.setLimitedQuantity(3);
        doctorPatientCheckInSettings.setFixedQuantity(null);
        return doctorPatientCheckInSettings;
    }

    public static void checkSaveDoctorPatientCheckInSettings(SaveDoctorPatientCheckInSettingsAO saveDoctorPatientCheckInSettingsAO) throws BizException {
        CommonTool.checkObj(saveDoctorPatientCheckInSettingsAO.getCheckInAllowedFlag(), "10050001");
        CommonTool.checkObj(saveDoctorPatientCheckInSettingsAO.getPatientSessionStatus(), "10050002");
        CommonTool.checkObj(saveDoctorPatientCheckInSettingsAO.getRuleType(), "10050003");
        if (saveDoctorPatientCheckInSettingsAO.getRuleType() == 0) {
            CommonTool.checkObj(saveDoctorPatientCheckInSettingsAO.getFreeDays(), "10050004");
            CommonTool.checkObj(saveDoctorPatientCheckInSettingsAO.getLimitedQuantity(), "10050005");
        }
        if (saveDoctorPatientCheckInSettingsAO.getRuleType() == 1) {
            CommonTool.checkObj(saveDoctorPatientCheckInSettingsAO.getFixedQuantity(), "10050006");
        }
    }

    public static DoctorPatientCheckInSettings buildSaveDoctorPatientCheckInSettings(SaveDoctorPatientCheckInSettingsAO saveDoctorPatientCheckInSettingsAO) {
        DoctorPatientCheckInSettings doctorPatientCheckInSettings = new DoctorPatientCheckInSettings();
        doctorPatientCheckInSettings.setDoctorId(ReqComTool.getUserId());
        doctorPatientCheckInSettings.setCheckInAllowedFlag(saveDoctorPatientCheckInSettingsAO.getCheckInAllowedFlag());
        doctorPatientCheckInSettings.setWelcomeMessage(saveDoctorPatientCheckInSettingsAO.getWelcomeMessage());
        doctorPatientCheckInSettings.setPatientSessionStatus(saveDoctorPatientCheckInSettingsAO.getPatientSessionStatus());
        doctorPatientCheckInSettings.setRuleType(saveDoctorPatientCheckInSettingsAO.getRuleType());
        if (saveDoctorPatientCheckInSettingsAO.getRuleType() == 0) {
            doctorPatientCheckInSettings.setFreeDays(saveDoctorPatientCheckInSettingsAO.getFreeDays());
            doctorPatientCheckInSettings.setLimitedQuantity(saveDoctorPatientCheckInSettingsAO.getLimitedQuantity());
        }
        if (saveDoctorPatientCheckInSettingsAO.getRuleType() == 1) {
            doctorPatientCheckInSettings.setFixedQuantity(saveDoctorPatientCheckInSettingsAO.getFixedQuantity());
        }
        return doctorPatientCheckInSettings;
    }

    public static DoctorPatientCheckInSettings buildSaveDoctorPatientCheckInSettings(DoctorPatientCheckInSettings doctorPatientCheckInSettings, SaveDoctorPatientCheckInSettingsAO saveDoctorPatientCheckInSettingsAO) {
        doctorPatientCheckInSettings.setCheckInAllowedFlag(saveDoctorPatientCheckInSettingsAO.getCheckInAllowedFlag());
        doctorPatientCheckInSettings.setWelcomeMessage(saveDoctorPatientCheckInSettingsAO.getWelcomeMessage());
        doctorPatientCheckInSettings.setPatientSessionStatus(saveDoctorPatientCheckInSettingsAO.getPatientSessionStatus());
        doctorPatientCheckInSettings.setRuleType(saveDoctorPatientCheckInSettingsAO.getRuleType());
        if (saveDoctorPatientCheckInSettingsAO.getRuleType() == 0) {
            doctorPatientCheckInSettings.setFreeDays(saveDoctorPatientCheckInSettingsAO.getFreeDays());
            doctorPatientCheckInSettings.setLimitedQuantity(saveDoctorPatientCheckInSettingsAO.getLimitedQuantity());
        }
        if (saveDoctorPatientCheckInSettingsAO.getRuleType() == 1) {
            doctorPatientCheckInSettings.setFixedQuantity(saveDoctorPatientCheckInSettingsAO.getFixedQuantity());
        }
        return doctorPatientCheckInSettings;
    }
}
